#!/bin/bash
#echo "pull imagestart" >> $HOME/log.txt
source $HOME/SwarmConfig/configs.sh

sudo -S sh -c 'echo 2048 > /sys/module/usbcore/parameters/usbfs_memory_mb'

if [ $CONFIG_NETWORK -eq 1 ]; then
    $HOME/Swarm_Docker/setup_adhoc.sh $DRONE_ID &
    echo "Wait 10 for network setup"
    /bin/sleep 10
fi

if [ $PULL_DOCKER -eq 1 ]; then
    /bin/bash $HOME/Swarm_Docker/pull_docker.sh >> $HOME/log.txt
fi 

if [ $START_DOCKER -eq 1 ]; then
    /bin/bash $HOME/Swarm_Docker/run_docker.sh -r >>$HOME/log.txt &
fi

echo "start swarmstart" >> $HOME/log.txt